package com.minimvc.patterns.mediator
{
	import com.minimvc.interfaces.IMediator;
	import com.minimvc.patterns.observer.Notifier;
	
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.events.IEventDispatcher;
	import flash.utils.Dictionary;
	
	
	/**
	 * 基本的视图中介调停者类,所有需要实现中介的类必须继承于此类;
	 * @author crl
	 * 
	 */	
	public class Mediator extends Notifier implements IMediator
	{		
		protected var name:String;
		protected var viewComponent:DisplayObject;
		protected var data:*;
		/**
		 * 中介所关心的事件列表; 
		 */		
		protected var _eventInterests:Dictionary;
		
		public function Mediator( mediatorName:String, view:DisplayObject=null ) {
			this.name = mediatorName;
			if(view)this.setView(view);	
			
			_eventInterests=new Dictionary(true);
		}

			
		public function getName():String 
		{	
			return name;
		}

		
		public function setView( view:DisplayObject):void 
		{
			this.viewComponent = view;
		}

			
		public function getView():DisplayObject
		{	
			return viewComponent;
		}
		
		public function getModel():*{
			return data;
		}
		public function setModel(model:*):void{
			data=model;
		}
		
		public function handle( event:Event ):void {
			//todo;
		}
		
		public function get eventInterests():Dictionary{
			return _eventInterests;
		}
		
		public function onRegister( ):void {
			
		}


		public function onRemove( ):void {
			
		}

		
	}
}